package org.bozo.im.service.protocols.xmpp.util.error;


/**
 * The following enumeration defines the error conditions that can be emitted from a stream level, as described in the Section 4.7.3 of [XMPP Core]. 
 * 
 * @author David Bidorff
 * @version 1.0
 *
 */
public enum ErrorConstraint {

	/**
	 * The entity has sent XML that cannot be processed; this error MAY be used instead of the more specific XML-related errors, such as
	 * <bad-namespace-prefix/>, <invalid-xml/>, <restricted-xml/>, <unsupported-encoding/>, and <xml-not-well-formed/>, although the more specific errors are
	 * preferred.
	 * 
	 * This error is represented by the node: <bad-format/>.
	 */
	BAD_FORMAT("bad-format"),

	/**
	 * The entity has sent a namespace prefix that is unsupported, or has sent no namespace prefix on an element that requires such a prefix (see XML
	 * Namespace Names and Prefixes (Section 11.2 of [XMPP Core])).
	 * 
	 * This error is represented by the node: <bad-namespace-prefix/>.
	 */
	BAD_NAMESPACE_PREFIX("bad-namespace-prefix"),

	/**
	 * The server is closing the active stream for this entity because a new stream has been initiated that conflicts with the existing stream.
	 * 
	 * This error is represented by the node: <conflict/>.
	 */
	CONFLICT("conflict"),

	/**
	 * The entity has not generated any traffic over the stream for some period of time (configurable according to a local service policy).
	 * 
	 * This error is represented by the node: <connection-timeout/>.
	 */
	CONNECTION_TIMEOUT("connection-timeout"),

	/**
	 * The value of the 'to' attribute provided by the initiating entity in the stream header corresponds to a hostname that is no longer hosted by the
	 * server.
	 * 
	 * This error is represented by the node: <host-gone/>.
	 */
	HOST_GONE("host-gone"),

	/**
	 * The value of the 'to' attribute provided by the initiating entity in the stream header does not correspond to a hostname that is hosted by the server.
	 * 
	 * This error is represented by the node: <host-unknown/>.
	 */
	HOST_UNKNOWN("host-unknown"),

	/**
	 * A stanza sent between two servers lacks a 'to' or 'from' attribute (or the attribute has no value).
	 * 
	 * This error is represented by the node: <improper-addressing/>.
	 */
	IMPROPER_ADDRESSING("improper-addressing"),

	/**
	 * The server has experienced a misconfiguration or an otherwise-undefined internal error that prevents it from servicing the stream.
	 * 
	 * This error is represented by the node: <internal-server-error/>.
	 */
	INTERNAL_SERVER_ERROR("internal-server-error"),

	/**
	 * The JID or hostname provided in a 'from' address does not match an authorized JID or validated domain negotiated between servers via SASL or dialback,
	 * or between a client and a server via authentication and resource binding.
	 *       
	 * This error is represented by the node: <invalid-from/>.
	 */
	INVALID_FROM("invalid-from"),

	/**
	 * The stream ID or dialback ID is invalid or does not match an ID previously provided.
	 * 
	 * This error is represented by the node: <invalid-id/>.
	 */
	INVALID_ID("invalid-id"),

	/**
	 * The streams namespace name is something other than "http://etherx.jabber.org/streams" or the dialback namespace name is something other than
	 * "jabber:server:dialback" (see XML Namespace Names and Prefixes (Section 11.2)).
	 *       
	 * This error is represented by the node: <invalid-namespace/>.
	 */
	INVALID_NAMESPACE("invalid-namespace"),

	/**
	 * The entity has sent invalid XML over the stream to a server that performs validation (see Validation (Section 11.3)).
	 *       
	 * This error is represented by the node: <invalid-xml/>.
	 */
	INVALID_XML("invalid-xml"),

	/**
	 * The entity has attempted to send data before the stream has been authenticated, or otherwise is not authorized to perform an action related to stream
	 * negotiation; the receiving entity MUST NOT process the offending stanza before sending the stream error.
	 * 
	 * This error is represented by the node: <not-authorized/>.
	 */
	NOT_AUTHORIZED("not-authorized"),

	/**
	 * The entity has violated some local service policy; the server MAY choose to specify the policy in the <text/> element or an application-specific
	 * condition element.
	 * 
	 * This error is represented by the node: <policy-violation/>.
	 */
	POLICY_VIOLATION("policy-violation"),

	/**
	 * The server is unable to properly connect to a remote entity that is required for authentication or authorization.
	 * 
	 * This error is represented by the node: <remote-connection-failed/>.
	 */
	REMOTE_CONNECTION_FAILED("remote-connection-failed"),

	/**
	 * The server lacks the system resources necessary to service the stream.
	 * 
	 * This error is represented by the node: <resource-constraint/>.
	 */
	RESOURCE_CONSTRAINT("resource-constraint"),

	/**
	 * The entity has attempted to send restricted XML features such as a comment, processing instruction, DTD, entity reference, or unescaped character (see
	 * Restrictions (Section 11.1)).
	 * 
	 * This error is represented by the node: <restricted-xml/>.
	 */
	RESTRICTED_XML("restricted-xml"),

	/**
	 * The server will not provide service to the initiating entity but is redirecting traffic to another host; the server SHOULD specify the alternate
	 * hostname or IP address (which MUST be a valid domain identifier) as the XML character data of the <see-other-host/> element.
	 * 
	 * This error is represented by the node: <see-other-host/>.
	 */
	SEE_OTHER_HOST("see-other-host"),

	/**
	 * The server is being shut down and all active streams are being closed.
	 * 
	 * This error is represented by the node: <system-shutdown/>.
	 */
	SYSTEM_SHUTDOWN("system-shutdown"),

	/**
	 * The error condition is not one of those defined by the other conditions in this list; this error condition SHOULD be used only in conjunction with an
	 * application-specific condition.
	 * 
	 * This error is represented by the node: <undefined-condition/>.
	 */
	UNDEFINED_CONDITION("undefined-condition"),

	/**
	 * The initiating entity has encoded the stream in an encoding that is not supported by the server (see Character Encoding (Section 11.5)).
	 * 
	 * This error is represented by the node: <unsupported-encoding/>.
	 */
	UNSUPPORTED_ENCODING("unsupported-encoding"),

	/**
	 * The initiating entity has sent a first-level child of the stream that is not supported by the server.
	 * 
	 * This error is represented by the node: <unsupported-stanza-type/>.
	 */
	UNSUPPORTED_STANZA_TYPE("unsupported-stanza-type"),

	/**
	 * The value of the 'version' attribute provided by the initiating entity in the stream header specifies a version of XMPP that is not supported by the
	 * server; the server MAY specify the version(s) it supports in the <text/> element.
	 * 
	 * This error is represented by the node: <unsupported-version/>.
	 */
	UNSUPPORTED_VERSION("unsupported-version"),

	/**
	 * The initiating entity has sent XML that is not well-formed as defined by [XML].
	 * 
	 * This error is represented by the node: <xml-not-well-formed/>.
	 */
	XML_NOT_WELL_FORMED("xml-not-well-formed");

	private String mValue;
	
	private ErrorConstraint(String pValue) {
		mValue = pValue;
	}
	
	@Override
	public String toString() {
		return mValue;
	}
	
}